home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
basic
/
dialogic.zip
/
EXAMPLE1.BAS
< prev
next >
Wrap
BASIC Source File
|
1990-01-31
|
8KB
|
194 lines
'
'┌───────────────────────────────────────────────────────┐
'│ Written by Jonathan S. Waldman │
'│ (C) 1989, 1990 Jonathan S. Waldman & Dialog Software │
'│ (C) Crescent Software. │
'│ All rights reserved. │
'└───────────────────────────────────────────────────────┘
'============
'DiaLogic
'EXAMPLE1.BAS
'============
'$INCLUDE: 'DIALOGIC.BI' 'include our DiaLogic TYPE definitions
'===========================================================================
'This program demonstrates the use of a single-tasking unstacked dialog box,
' and shows that even though dialog boxes are unstacked, it does not mean
' they can't be fully-functional.
'
'In this example program you may enter a search string and select various
' options. If you choose <Help> a new dialog box will appear with help
' text. When you are finished reading the help, you may close the dialog
' box by pressing <Enter>. At this point, this program will re-generate
' the Find dialog box by filling it with all the options you chose before
' <Help> was requested. The Find dialog box will continue to appear until
' Help is NOT chosen or until <Esc> is pressed.
'
'Please notice that this example defines some strings for convenience and
' enhanced readability, such as ESC$ and Help$. You should also notice
' that the Find template also includes these strings in the command button
' definitions. Further, other variables, such as Search$ and WholeWord,
' are used to set a re-generated Find dialog box to its previously-set
' values.
'===========================================================================
'====================
'Initialize the mouse
'====================
CALL InitMouse(There%) 'see if mouse and driver are there
IF There% THEN 'if yes then
CALL ShowCursor 'show the mouse
CALL TextCursor(0, 4) 'use this to insure mouse is always visible
END IF
'======
'Set-up
'======
CALL HideCursor
WIDTH , 25 'insure we're in 25-line mode
COLOR 15, 1
CLS 'clear the screen
'========================
'REDIM the arrays for now
'========================
'$DYNAMIC 'make all arrays dynamic
MaxDBE = 20 'use for our dimension statements
' 20 dialog box elements will be our max
REDIM SHARED DB(1, MaxDBE) AS DialogType 'REDIM these TYPE arrays
REDIM SHARED LB(0) AS DialogText ' dynamically
PRINT
PRINT " This is a single-tasking dialog box."
PRINT
PRINT " Observe that <Help> closes the Find dialog box and removes it from the"
PRINT " screen and then generates a Help dialog box. Note also that any"
PRINT " selections made on the Find dialog box (before help is requested) are"
PRINT " preserved when the Find dialog box is regenerated. Help is NOT avail-"
PRINT " able with <F1> in this example."
PRINT : PRINT
CALL ShowCursor
'=======================================
'Define some convenient string variables
'=======================================
Cancel$ = CHR$(27) 'these are our string assignments, also used
Help$ = CHR$(0) + CHR$(59) ' in the FIND.DB template.
OK$ = CHR$(13)
Search$ = "" 'initialize Search$ to null
ExitLoop = 0 'initialize our DO loop variable to 0
'=================
'start the DO loop
'=================
DO
'******************************************************************
GOSUB FindDBSetUp 'prepare for the Find dialog box
' then generate it by calling DiaLogic
CALL DiaLogic(DB(), LB(), Action%, Focus%, Ky$)
'******************************************************************
'======================================================================
'When program execution returns here the dialog box already will have
'been cleared from the screen since Action 0 was used. If <Help> is
'chosen we'll generate a Help dialog box. We'll also check to see if
'<Esc> was pressed or if <OK> was entered, in which case we can get the
'search string and conduct a search.
'======================================================================
'Now we can store dialog box information in local variables. These
' variables also appear in the template definition. Level% will still
' be 1. Notice that the second subscript, the Sequence number, is
' used to access information for particular dialog box elements in
' the template.
Search$ = MID$(DB(Level%, 2).TextString, 1, DB(Level%, 2).NumberOne)
'Search$ holds our search string
MatchCase = DB(Level%, 3).Default '-1 if Match Case is checked
WholeWord = DB(Level%, 4).Default '-1 if Whole Words is checked
SearchType = DB(Level%, 5).Default ' 1 for Active Window, 2 for
' Current Module, or 3 for
' All Modules
'====================================================================
'below we are processing the call to DiaLogic to see what was entered
'into the dialog box
'====================================================================
SELECT CASE Ky$
CASE Cancel$ '<Cancel> pressed (the <Cancel> button
' was defined to Esc$ in the template
PRINT " You pushed <Cancel>."
ExitLoop = -1 'exit the do loop
CASE Help$
'================================================================
'Since the user chose help we must generate another dialog box.
' This time it will be a Help dialog box for the Find dialog
' box.
'================================================================
GOSUB HelpDBSetUp
CALL DiaLogic(DB(), LB(), Action%, Focus%, Ky$)
CASE OK$
PRINT " You pushed <OK>."
ExitLoop = -1
CASE ELSE
BEEP 'bad value returned
END SELECT
LOOP UNTIL ExitLoop
'=======================================================================
'Print the results to the user. This is for demonstration purposes only
' to show that the calling program has correctly received information
' from the dialog box.
'=======================================================================
PRINT " Your search string is " + LEFT$(Search$, 40) + " ..."
IF MatchCase THEN
PRINT " Match Upper/Lower Case was checked."
END IF
IF WholeWord THEN
PRINT " Whole Words Only was checked."
END IF
PRINT " " + RTRIM$(MID$(DB(Level%, 5 + SearchType).Text, 5)) + " was selected."
COLOR 7, 0
CALL HideCursor
END
'=============================
'Dialog box set-up subroutines
'=============================
FindDBSetUp:
REDIM SHARED DB(1, MaxDBE) AS DialogType 'REDIM these TYPE arrays
REDIM SHARED LB(0) AS DialogText ' dynamically
Level% = 1 'set Level% to 1
'$INCLUDE: 'FIND.DB' 'include the Find dialog box template
Action% = 0 'set Action% to 0
Focus% = 0 'set the input focus to auto -- 0
RETURN
HelpDBSetUp:
REDIM SHARED DB(1, MaxDBE) AS DialogType 'REDIM these TYPE arrays
REDIM SHARED LB(10) AS DialogText
Level% = 1 'set Level% to 1
'$INCLUDE: 'FINDH.DB' 'include Help dialog box template
Action% = 0 'set Action% to 0
Focus% = 0 'set the input focus to auto -- 0
RETURN